﻿import "../lib/ace/ace.min.js";
import "../lib/ace/mode-text.min.js";


//mode nc
define('ace/mode/nc', ['require', 'exports', 'module', 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/nc_highlight_rules'], function (require, exports, module) {
    var oop = require("ace/lib/oop");
    var TextMode = require("ace/mode/text").Mode;
    var Tokenizer = require('ace/tokenizer').Tokenizer;
    var NCHighlightRules = require("ace/mode/nc_highlight_rules").NCHighlightRules;

    var Mode = function () {
        this.HighlightRules = NCHighlightRules;
    };
    oop.inherits(Mode, TextMode);

    (function () {
        this.$id = "ace/mode/nc";
        this.lineCommentStart = ";"; // Optional: NC code can use different line comment symbols
    }).call(Mode.prototype);

    exports.Mode = Mode;
});
define('ace/mode/nc_highlight_rules', ['require', 'exports', 'module', 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function (require, exports, module) {
    var oop = require("ace/lib/oop");
    var TextHighlightRules = require("ace/mode/text_highlight_rules").TextHighlightRules;

    var NCHighlightRules = function () {
        this.$rules = {
            "start": [
                //{
                //    // index at line start (e.g. N0021)
                //    token: "line-start-index",
                //    regex: /N\d+/
                //},
                {
                    // G-codes and M-codes (e.g., G01, M03)
                    token: "keyword",
                    regex: /(G|M)\d+\.?\d*/
                },
                {
                    // Coordinates (e.g., X10.5, Y-3.2,I3.)
                    token: "nc-move",
                    regex: /[XYIJKR][-+]?\d*\.?\d*/
                },
                {
                    token: "nc-z",
                    regex: /Z[-+]?\d*\.?\d*/
                },
                {
                    // Comments in parentheses
                    token: "comment",
                    regex: /\(.*\)/
                },
                {
                    // Other letters like T (tool), S (spindle speed), F (feed rate)
                    token: "variable",
                    regex: /[TSF][-+]?\d*\.?\d*/
                },
                {
                    token: "cs-script",
                    regex: /;[@#].*$/
                },
                {
                    token: "text", // 其他內容
                    regex: /\s+/
                }
            ]
        };
    };

    oop.inherits(NCHighlightRules, TextHighlightRules);
    exports.NCHighlightRules = NCHighlightRules;
});


//mode csv
define('ace/mode/csv', ['require', 'exports', 'module', 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/csv_highlight_rules'], function (require, exports, module) {
    var oop = require('ace/lib/oop');
    var TextMode = require('ace/mode/text').Mode;
    var Tokenizer = require('ace/tokenizer').Tokenizer;
    var CsvHighlightRules = require('ace/mode/csv_highlight_rules').CsvHighlightRules;

    var Mode = function () {
        this.HighlightRules = CsvHighlightRules;
    };
    oop.inherits(Mode, TextMode);

    (function () {
        this.$id = "ace/mode/csv";
    }).call(Mode.prototype);

    exports.Mode = Mode;
});
define('ace/mode/csv_highlight_rules', ['require', 'exports', 'module', 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function (require, exports, module) {
    var oop = require('ace/lib/oop');
    var TextHighlightRules = require('ace/mode/text_highlight_rules').TextHighlightRules;

    var CsvHighlightRules = function () {
        this.$rules = {
            "start": [
                {
                    token: "punctuation", // 逗號
                    regex: /,/
                },
                {
                    token: "string", // 文字（雙引號內的內容）
                    regex: /"(?:[^"]|"")*"/
                },
                {
                    token: "constant.numeric", // 數字
                    regex: /\b\d+\b/
                },
                {
                    token: "text", // 其他內容
                    regex: /\s+/
                }
            ]
        };
    };

    oop.inherits(CsvHighlightRules, TextHighlightRules);
    exports.CsvHighlightRules = CsvHighlightRules;
});
